/*
 * Copyright (c) 2014 laidian. All Rights Reserved.
 * 
 * @author yaoyuming
 * 
 * @date 2019-11-27 20:54
 */
package com.yao.cloud.consumer.config;

import cn.hutool.core.lang.Console;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author yaoyuming
 * @date 2019/11/27 20:54
 */
@Configuration
public class RestTemplateConfig {

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    /**
     * 功能描述 : 全局配置负载均衡策略
     * @param
     * @author yaoyuming
     * @date 2019/12/4
     * @return {@link IRule}
     */
    @Bean
    public IRule ribbonRule(){
        Console.log("全局配置Ribbon负载均衡策略");
        return new RandomRule();
    }
}